


import 'dart:io';

import 'package:device_info_plus/device_info_plus.dart';

import 'common_device_info.dart';

class DeviceInfo{

  static Future<BaseDeviceInfo> getBaseDeviceInfo() async {
    DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
    BaseDeviceInfo info= await deviceInfo.deviceInfo;
    return info;
  }

  static Future<CommonDeviceInfo> getCommonDeviceInfo() async{
     DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();

     if(Platform.isAndroid){
       AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
       return CommonDeviceInfo(
           androidInfo.serialNumber,'android',"0.0.1","11.0"
       );
     }else if(Platform.isIOS){
       IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
       return CommonDeviceInfo(
           iosInfo.identifierForVendor!,'android',"0.0.1","11.0"
       );
     }
     return CommonDeviceInfo(
         'unkown','android',"0.0.1","11.0"
     );
  }

  static Future<String> getDeviceInfo() async {
    DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
    String deviceInfoString = '';

    if (Platform.isAndroid) {
      AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
      deviceInfoString = 'Model: ${androidInfo.model}, '
          'Brand: ${androidInfo.brand}, '
          'Device: ${androidInfo.device}, '
          'Board: ${androidInfo.board}, '
          'Board: ${androidInfo.board}, '
          'Hardware: ${androidInfo.hardware}, '
          'Product: ${androidInfo.product}, '
          'Device ID: ${androidInfo.id}';
    } else if (Platform.isIOS) {
      IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
      deviceInfoString = 'Model: ${iosInfo.model}, '
          'Localized Model: ${iosInfo.localizedModel}, '
          'Device ID: ${iosInfo.identifierForVendor}';
    }

    return deviceInfoString;
  }
}
